<template>
  <div>
    <div class="title">我的关注</div>
    <div class="list">
      <div class="col" v-for="item in list" :key="item.id">
        <div class="item">
          <div class="imgDiv"><img :src="item.avatar" alt="" /></div>
          <div class="content">
            <div class="name">{{ item.nickname }}</div>
          </div>
          <div class="option">
            <div class="btn pointer" @click="handleShow(item)">查看</div>
            <div class="btn pointer" @click="handleDel(item)">取消</div>
          </div>
        </div>
      </div>
    </div>
    <pagination
      :total="total"
      :currentPage="page"
      :pageSize="rows"
      @handleCurrentChange="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: "NavBar",
  data() {
    return { page: 1, total: 0, list: [], rows: 10 };
  },
  components: {
    pagination: () => import("@/components/pagination.vue"),
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      this.$post("/user/follow_list", {
        page: this.page,
        rows: this.rows,
      }).then((res) => {
        this.list = res.data.data;
        this.total = res.data.total;
      });
    },
    handleCurrentChange(e) {
      this.page = e;
      this.getList();
    },
    handleShow(item) {
      window.open("/cameramanDetail?id=" + item.follow_id);
    },
    handleDel(item) {
      this.$confirm("您确认删除？", "删除信息", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$post("/user/follow_del", { follow_id: item.id }).then(
            (res) => {
              if (res.code == 1) {
                this.$message.success("取消关注");
                setTimeout(() => {
                  this.getList();
                }, 1000);
              }
            }
          );
        })
        .catch(() => {
          // 用户点击取消按钮或关闭对话框时执行
        });
    },
  },
};
</script>

<style scoped lang="scss">
.title {
  font-size: 24px;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  padding: 6px 0 10px;

  .col {
    padding: 5px;
    .item {
      font-size: 16px;
      line-height: 30px;
      padding: 0 15px;
      background: #f8f8f8;
      border-radius: 4px;
      color: #565656;
    }
    .active {
      color: #fff;
      background: #917bbd;
    }
  }
}
.list {
  display: flex;
  flex-wrap: wrap;
  .col {
    width: calc(100% / 3);
    padding: 5px;
    .imgDiv {
      height: 240px;
      border-top-left-radius: 8px;
      border-top-right-radius: 8px;
    }
    .content{
      background-color: #eee;
      .name{
        text-align: center;
      }
    }
    .option {
      //position: absolute;
      background: rgba($color: #917bbd, $alpha: 0.9);
      color: #fff;
      display: flex;
      align-items: center;
      width: 100%;
      left: 0;
      bottom: 0;
      height: 40px;
      border-bottom-left-radius: 8px;
      border-bottom-right-radius: 8px;
      .btn {
        text-align: center;
        width: 100%;
        font-size: 16px;
      }
    }
  }
}
@media screen and (max-width: 768px) {
}
</style>
